What are the top tags selected when disaggregated?

By locale

disag_locale <- full %>% 
  select(school_id, locale = exclusive_locale, starts_with("practices")) %>% 
  pivot_longer(cols = starts_with("practices"),
               names_to = "tag",
               values_to = "n") %>% 
  select(!school_id) %>% 
  mutate(rate = rep(1, nrow(.))) %>% 
  group_by(locale, tag) %>% 
  summarize(n = sum(n),
            rate = sum(rate),
            pct = n/rate) %>% 
  ungroup() %>% 
  group_by(locale) %>% 
  arrange(desc(n), .by_group = TRUE) %>% 
  slice(1:5)
## `summarise()` has grouped output by 'locale'. You can override using the
## `.groups` argument.
# urban
urban_plot <- disag_locale %>% 
  filter(locale == "Urban") %>% 
  ggplot(., aes(reorder(tag, pct), pct)) +
  geom_col(fill = transcend_cols[1]) +
  scale_x_discrete(labels = label_tags(wrap = 25)) +
  coord_flip() +
  scale_y_continuous(limits = c(0, 1), 
                     expand = c(0,0),
                     labels = scales::percent) +
  labs(title = "Top Practices in Urban Schools",
       x = "",
       y = "percentage of urban schools")
urban_plot

# suburban
suburban_plot <- disag_locale %>% 
  filter(locale == "Suburban") %>% 
  ggplot(., aes(reorder(tag, pct), pct)) +
  geom_col(fill = transcend_cols[2]) +
  scale_x_discrete(labels = label_tags(wrap = 25)) +
  coord_flip() +
  scale_y_continuous(limits = c(0, 1), 
                     expand = c(0,0),
                     labels = scales::percent) +
  labs(title = "Top Practices in Suburban Schools",
       x = "",
       y = "percentage of suburban schools")
suburban_plot

# rural
rural_plot <- disag_locale %>% 
  filter(locale == "Rural") %>% 
  ggplot(., aes(reorder(tag, pct), pct)) +
  geom_col(fill = transcend_cols[3]) +
  scale_x_discrete(labels = label_tags(wrap = 25)) +
  coord_flip() +
  scale_y_continuous(limits = c(0, 1), 
                     expand = c(0,0),
                     labels = scales::percent) +
  labs(title = "Top Practices in Rural Schools",
       x = "",
       y = "percentage of rural schools")
rural_plot

# mixed
mixed_plot <- disag_locale %>% 
  filter(locale == "Multiple") %>% 
  ggplot(., aes(reorder(tag, pct), pct)) +
  geom_col(fill = transcend_cols[4]) +
  scale_x_discrete(labels = label_tags(wrap = 25)) +
  coord_flip() +
  scale_y_continuous(limits = c(0, 1), 
                     expand = c(0,0),
                     labels = scales::percent) +
  labs(title = "Top Practices in Schools Serving\nStudents from all Geographic Locales",
       x = "",
       y = "percentage of mixed schools")
mixed_plot

By level

#prekindergarten
disag_pk <- full %>% 
  select(school_id, grades_prek, starts_with("practices")) %>% 
  filter(grades_prek == 1) %>% 
  pivot_longer(cols = starts_with("practices"),
               names_to = "tag",
               values_to = "n") %>% 
  select(!school_id) %>% 
  mutate(rate = rep(1, nrow(.))) %>% 
  group_by(tag) %>% 
  summarize(n = sum(n),
            rate = sum(rate),
            pct = n/rate) %>% 
  ungroup() %>% 
  arrange(desc(n)) %>% 
  slice(1:5) %>% 
  ggplot(., aes(reorder(tag, pct), pct)) +
  geom_col(fill = transcend_cols[1]) +
  scale_x_discrete(labels = label_tags(wrap = 25)) +
  coord_flip() +
  scale_y_continuous(limits = c(0, 1), 
                     expand = c(0,0),
                     labels = scales::percent) +
  labs(title = "Top Practices in Pre-Kindergarten Schools",
       x = "",
       y = "percentage of prek schools")
disag_pk

# elementary schools
disag_elem <- full %>% 
  select(school_id, grades_elementary, starts_with("practices")) %>% 
  filter(grades_elementary == 1) %>% 
  pivot_longer(cols = starts_with("practices"),
               names_to = "tag",
               values_to = "n") %>% 
  select(!school_id) %>% 
  mutate(rate = rep(1, nrow(.))) %>% 
  group_by(tag) %>% 
  summarize(n = sum(n),
            rate = sum(rate),
            pct = n/rate) %>% 
  ungroup() %>% 
  arrange(desc(n)) %>% 
  slice(1:5) %>% 
  ggplot(., aes(reorder(tag, pct), pct)) +
  geom_col(fill = transcend_cols[2]) +
  scale_x_discrete(labels = label_tags(wrap = 25)) +
  coord_flip() +
  scale_y_continuous(limits = c(0, 1), 
                     expand = c(0,0),
                     labels = scales::percent) +
  labs(title = "Top Practices in Elementary Schools",
       x = "",
       y = "percentage of elementary schools")
disag_elem

#middle schools
disag_middle <- full %>% 
  select(school_id, grades_middle, starts_with("practices")) %>% 
  filter(grades_middle == 1) %>% 
  pivot_longer(cols = starts_with("practices"),
               names_to = "tag",
               values_to = "n") %>% 
  select(!school_id) %>% 
  mutate(rate = rep(1, nrow(.))) %>% 
  group_by(tag) %>% 
  summarize(n = sum(n),
            rate = sum(rate),
            pct = n/rate) %>% 
  ungroup() %>% 
  arrange(desc(n)) %>% 
  slice(1:5) %>% 
  ggplot(., aes(reorder(tag, pct), pct)) +
  geom_col(fill = transcend_cols[3]) +
  scale_x_discrete(labels = label_tags(wrap = 25)) +
  coord_flip() +
  scale_y_continuous(limits = c(0, 1), 
                     expand = c(0,0),
                     labels = scales::percent) +
  labs(title = "Top Practices in Middle Schools",
       x = "",
       y = "percentage of middle schools")
disag_middle

#high schools
disag_high <- full %>% 
  select(school_id, grades_high, starts_with("practices")) %>% 
  filter(grades_high == 1) %>% 
  pivot_longer(cols = starts_with("practices"),
               names_to = "tag",
               values_to = "n") %>% 
  select(!school_id) %>% 
  mutate(rate = rep(1, nrow(.))) %>% 
  group_by(tag) %>% 
  summarize(n = sum(n),
            rate = sum(rate),
            pct = n/rate) %>% 
  ungroup() %>% 
  arrange(desc(n)) %>% 
  slice(1:5) %>% 
  ggplot(., aes(reorder(tag, pct), pct)) +
  geom_col(fill = transcend_cols[4]) +
  scale_x_discrete(labels = label_tags(wrap = 25)) +
  coord_flip() +
  scale_y_continuous(limits = c(0, 1), 
                     expand = c(0,0),
                     labels = scales::percent) +
  labs(title = "Top Practices in High Schools",
       x = "",
       y = "percentage of high schools")
disag_high

By school type

disag_type <- full %>% 
  select(school_id, type = school_descriptor, starts_with("practices")) %>% 
  mutate(type = case_when(
    type == 1 ~ "District",
    type == 2 ~ "Charter",
    type == 3 ~ "Independent"
  )) %>% 
  pivot_longer(cols = starts_with("practices"),
               names_to = "tag",
               values_to = "n") %>% 
  select(!school_id) %>% 
  mutate(rate = rep(1, nrow(.))) %>% 
  group_by(type, tag) %>% 
  summarize(n = sum(n),
            rate = sum(rate),
            pct = n/rate) %>% 
  ungroup() %>% 
  group_by(type) %>% 
  arrange(desc(n), .by_group = TRUE) %>% 
  slice(1:5)
## `summarise()` has grouped output by 'type'. You can override using the
## `.groups` argument.
#Public district schools
district_plot <- disag_type %>% 
  filter(type == "District") %>% 
  ggplot(., aes(reorder(tag, pct), pct)) +
  geom_col(fill = transcend_cols[1]) +
  scale_x_discrete(labels = label_tags(wrap = 25)) +
  coord_flip() +
  scale_y_continuous(limits = c(0, 1), 
                     expand = c(0,0),
                     labels = scales::percent) +
  labs(title = "Top Practices in Public District Schools",
       x = "",
       y = "percentage of district schools")
district_plot

#Public charter schools
charter_plot <- disag_type %>% 
  filter(type == "Charter") %>% 
  ggplot(., aes(reorder(tag, pct), pct)) +
  geom_col(fill = transcend_cols[2]) +
  scale_x_discrete(labels = label_tags(wrap = 25)) +
  coord_flip() +
  scale_y_continuous(limits = c(0, 1), 
                     expand = c(0,0),
                     labels = scales::percent) +
  labs(title = "Top Practices in Public Charter Schools",
       x = "",
       y = "percentage of charter schools")
charter_plot

#Independent schools
independent_plot <- disag_type %>% 
  filter(type == "Independent") %>% 
  ggplot(., aes(reorder(tag, pct), pct)) +
  geom_col(fill = transcend_cols[3]) +
  scale_x_discrete(labels = label_tags(wrap = 25)) +
  coord_flip() +
  scale_y_continuous(limits = c(0, 1), 
                     expand = c(0,0),
                     labels = scales::percent) +
  labs(title = "Top Practices in Independent (Private) Schools",
       x = "",
       y = "percentage of independent schools")
independent_plot

By descriptors

These plots are somewhat misleading and probably should not be displayed due to low N. For homeschools in particular, because there were only 4 schools that described themselves that way and 6 instances where they all selected the same tags, the plot displays a full 100% barchart for all 6 tags. Drawing any conclusions from this would not be a good idea, though.

For reference: homeschool N = 4
hybrid N = 21
microschool N =
school-within-school N =
*virtual N =

#homeschool
disag_homeschool <- full %>% 
  select(school_id, homeschool = school_descriptor_homeschool, starts_with("practices")) %>% 
  filter(homeschool == 1) %>% 
  pivot_longer(cols = starts_with("practices"),
               names_to = "tag",
               values_to = "n") %>% 
  select(!school_id) %>% 
  mutate(rate = rep(1, nrow(.))) %>% 
  group_by(tag) %>% 
  summarize(n = sum(n),
            rate = sum(rate),
            pct = n/rate) %>% 
  ungroup() %>% 
  arrange(desc(n)) %>% 
  slice(1:6) %>% #pulled 6 because #5 had a tie with another practice -6 tags had 100% selection
  ggplot(., aes(reorder(tag, pct), pct)) +
  geom_col(fill = transcend_cols[1]) +
  scale_x_discrete(labels = label_tags(wrap = 25)) +
  coord_flip() +
  scale_y_continuous(limits = c(0, 1), 
                     expand = c(0,0),
                     labels = scales::percent) +
  labs(title = "Top Practices in Homeschools",
       subtitle = "Interpret with caution: only 4 homeschools",
       x = "",
       y = "percentage of homeschools")
disag_homeschool

#hybrid
disag_hybrid <- full %>% 
  select(school_id, hybrid = school_descriptor_hybrid, starts_with("practices")) %>% 
  filter(hybrid == 1) %>% 
  pivot_longer(cols = starts_with("practices"),
               names_to = "tag",
               values_to = "n") %>% 
  select(!school_id) %>% 
  mutate(rate = rep(1, nrow(.))) %>% 
  group_by(tag) %>% 
  summarize(n = sum(n),
            rate = sum(rate),
            pct = n/rate) %>% 
  ungroup() %>% 
  arrange(desc(n)) %>% 
  slice(1:4) %>% #pulled 4 because 7 tags shared #5 spot
  ggplot(., aes(reorder(tag, pct), pct)) +
  geom_col(fill = transcend_cols[2]) +
  scale_x_discrete(labels = label_tags(wrap = 25)) +
  coord_flip() +
  scale_y_continuous(limits = c(0, 1), 
                     expand = c(0,0),
                     labels = scales::percent) +
  labs(title = "Top Practices in Hybrid Schools",
       x = "",
       y = "percentage of hybrid schools")
disag_hybrid

#microschool
disag_micro <- full %>% 
  select(school_id, micro = school_descriptor_microschool, starts_with("practices")) %>% 
  filter(micro == 1) %>% 
  pivot_longer(cols = starts_with("practices"),
               names_to = "tag",
               values_to = "n") %>% 
  select(!school_id) %>% 
  mutate(rate = rep(1, nrow(.))) %>% 
  group_by(tag) %>% 
  summarize(n = sum(n),
            rate = sum(rate),
            pct = n/rate) %>% 
  ungroup() %>% 
  arrange(desc(n)) %>% 
  slice(1:5) %>% #top 5 had same rate of selection (87%)
  ggplot(., aes(reorder(tag, pct), pct)) +
  geom_col(fill = transcend_cols[3]) +
  scale_x_discrete(labels = label_tags(wrap = 25)) +
  coord_flip() +
  scale_y_continuous(limits = c(0, 1), 
                     expand = c(0,0),
                     labels = scales::percent) +
  labs(title = "Top Practices in Microschools",
       subtitle = "The top 5 tags selected for microschools shared the same\nrate of selection",
       x = "",
       y = "percentage of microschools")
disag_micro

#school within school
disag_sws <- full %>% 
  select(school_id, sws = school_descriptor_sws, starts_with("practices")) %>% 
  filter(sws == 1) %>% 
  pivot_longer(cols = starts_with("practices"),
               names_to = "tag",
               values_to = "n") %>% 
  select(!school_id) %>% 
  mutate(rate = rep(1, nrow(.))) %>% 
  group_by(tag) %>% 
  summarize(n = sum(n),
            rate = sum(rate),
            pct = n/rate) %>% 
  ungroup() %>% 
  arrange(desc(n)) %>% 
  slice(1:6) %>% #pulled 6 because tie at spot #5
  ggplot(., aes(reorder(tag, pct), pct)) +
  geom_col(fill = transcend_cols[4]) +
  scale_x_discrete(labels = label_tags(wrap = 25)) +
  coord_flip() +
  scale_y_continuous(limits = c(0, 1), 
                     expand = c(0,0),
                     labels = scales::percent) +
  labs(title = "Top Practices in Schools-within-schools",
       x = "",
       y = "percentage of school-within-schools")
disag_sws

#virtual

By leadership team

I collapsed leadership team diversity variable in two:
predominantly White = 0-49% BIPOC leadership
predominantly BIPOC = 50% + BIPOC leadership

disag_lead <- full %>% 
  select(school_id, lead = leadership_diversity, starts_with("practices")) %>% 
  filter(!lead == 0) %>% 
  filter(!lead == 5) %>% 
  mutate(lead = case_when(
    (lead == 1 | lead == 2) ~ "PWI",
    (lead == 3 | lead == 4) ~ "BIPOC"
  )) %>% 
  pivot_longer(cols = starts_with("practices"),
               names_to = "tag",
               values_to = "n") %>% 
  select(!school_id) %>% 
  mutate(rate = rep(1, nrow(.))) %>% 
  group_by(lead, tag) %>% 
  summarize(n = sum(n),
            rate = sum(rate),
            pct = n/rate) %>% 
  ungroup() %>% 
  group_by(lead) %>% 
  arrange(desc(n), .by_group = TRUE) %>% 
  slice(1:6) #tie at spot #5 for both groups
## `summarise()` has grouped output by 'lead'. You can override using the
## `.groups` argument.
#predominantly white
pwled_plot <- disag_lead %>% 
  filter(lead == "PWI") %>% 
  ggplot(., aes(reorder(tag, pct), pct)) +
  geom_col(fill = transcend_cols[1]) +
  scale_x_discrete(labels = label_tags(wrap = 25)) +
  coord_flip() +
  scale_y_continuous(limits = c(0, 1), 
                     expand = c(0,0),
                     labels = scales::percent) +
  labs(title = "Top Practices in Schools led\nby Predominantly White\nLeadership Team",
       x = "",
       y = "percentage of schools")
pwled_plot

#BIPOC-led
bipocled_plot <- disag_lead %>% 
  filter(lead == "BIPOC") %>% 
  ggplot(., aes(reorder(tag, pct), pct)) +
  geom_col(fill = transcend_cols[2]) +
  scale_x_discrete(labels = label_tags(wrap = 25)) +
  coord_flip() +
  scale_y_continuous(limits = c(0, 1), 
                     expand = c(0,0),
                     labels = scales::percent) +
  labs(title = "Top Practices in Schools led\nby Predominantly BIPOC\nLeadership Team",
       x = "",
       y = "percentage of schools")
bipocled_plot

#combine plots
# combined <-
plot_grid(pwled_plot, bipocled_plot, 
          ncol = 2)
## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
## 'Open Sans' not found in PostScript font database

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
## 'Open Sans' not found in PostScript font database

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
## 'Open Sans' not found in PostScript font database

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
## 'Open Sans' not found in PostScript font database

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
## 'Open Sans' not found in PostScript font database

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
## 'Open Sans' not found in PostScript font database

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
## 'Open Sans' not found in PostScript font database

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
## 'Open Sans' not found in PostScript font database

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
## 'Open Sans' not found in PostScript font database

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
## 'Open Sans' not found in PostScript font database

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
## 'Open Sans' not found in PostScript font database

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
## 'Open Sans' not found in PostScript font database

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
## 'Open Sans' not found in PostScript font database

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
## 'Open Sans' not found in PostScript font database
## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
## 'Bebas Neue' not found in PostScript font database

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
## 'Bebas Neue' not found in PostScript font database

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
## 'Bebas Neue' not found in PostScript font database

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
## 'Bebas Neue' not found in PostScript font database

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
## 'Bebas Neue' not found in PostScript font database

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
## 'Bebas Neue' not found in PostScript font database

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
## 'Bebas Neue' not found in PostScript font database

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
## 'Bebas Neue' not found in PostScript font database

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
## 'Bebas Neue' not found in PostScript font database

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
## 'Bebas Neue' not found in PostScript font database

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
## 'Bebas Neue' not found in PostScript font database

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
## 'Bebas Neue' not found in PostScript font database

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
## 'Bebas Neue' not found in PostScript font database

## Warning in grid.Call(C_stringMetric, as.graphicsAnnot(x$label)): font family
## 'Bebas Neue' not found in PostScript font database

# ggsave("finding-17.png", plot = combined, path = here("final_products", "draft-findings"),
#        width = 12, height = 8, units = "in")

By designing for specific student groups

The plots below pull from all schools that selected design to meet the needs of students who have been marginalized and the follow-up question which asks them to specify which marginalized student group they are designing for.

Which student groups?

The chart below displays the frequency with which Canopy learning environments identified specific student groups as the historically marginalized groups they’re designing their schools for.

marg_freq <- full %>% 
  select(starts_with("focus"), practices_design_marginalized) %>% #191/251 schools selected
  select(!focus_other_student_group_text) %>% 
  filter(practices_design_marginalized == 1) %>% 
  mutate(rate = rep(1, nrow(.))) %>% 
  summarise(across(where(is.numeric), ~ sum(.x, na.rm = TRUE))) %>% 
  pivot_longer(cols = starts_with("focus"),
               names_to = "group",
               values_to = "n") %>% 
  mutate(pct = n/rate,
         group = case_when(
           group == "focus_bipoc" ~ "BIPOC students",
           group == "focus_economic_disadvantage" ~ "Economically Disadvantaged Students",
           group == "focus_emergent_bilingual" ~ "Students Classified as English Learners",
           group == "focus_foster" ~ "Students in the Foster Care System",
           group == "focus_homeless" ~ "Students Experiencing Houselessness",
           group == "focus_interrupted" ~ "Students with Interrupted Formal Education",
           group == "focus_juvenile_justice" ~ "Students in the Juvenile Justice System",
           group == "focus_multilingual" ~ "Multilingual Students",
           group == "focus_newcomer" ~ "Newcomer and Recently Arrived Students",
           group == "focus_other_student_group" ~ "Other",
           group == "focus_swd" ~ "Students with Disabilities"
         )) %>% 
  ggplot(., aes(reorder(group, pct), pct)) +
  geom_col(fill = transcend_cols[1]) +
  scale_x_discrete(labels = label_tags(wrap = 25)) +
  coord_flip() +
  scale_y_continuous(limits = c(0, 1), 
                     expand = c(0,0),
                     labels = scales::percent) +
  labs(title = "When schools are designing for margianlized groups,\nwhich groups are they designing for?",
       x = "",
       y = "percentage of schools indicating designing for specific student groups")
marg_freq
## Warning in labels(...): Missing tag label

# ggsave("finding-18.png", plot = marg_freq, path = here("final_products", "draft-findings"),
#        width = 12, height = 8, units = "in")

Multilingual students

disag_ml <- full %>% 
  select(school_id, ml = focus_multilingual, starts_with("practices")) %>% 
  filter(ml == 1) %>% 
  select(!practices_design_marginalized) %>% #dropping since all will have chosen
  pivot_longer(cols = starts_with("practices"),
               names_to = "tag",
               values_to = "n") %>% 
  select(!school_id) %>% 
  mutate(rate = rep(1, nrow(.))) %>% 
  group_by(tag) %>% 
  summarize(n = sum(n),
            rate = sum(rate),
            pct = n/rate) %>% 
  ungroup() %>% 
  arrange(desc(n)) %>% 
  slice(1:6) %>% #pulled 6 because tie at spot #5
  ggplot(., aes(reorder(tag, pct), pct)) +
  geom_col(fill = transcend_cols[4]) +
  scale_x_discrete(labels = label_tags(wrap = 25)) +
  coord_flip() +
  scale_y_continuous(limits = c(0, 1), 
                     expand = c(0,0),
                     labels = scales::percent) +
  labs(title = "Top Practices in Schools Designing for Multilingual students",
       x = "",
       y = "percentage of schools")
disag_ml

Students classified as English Learners

Students with interrupted formal education

Newcomer students

BIPOC students

Economically disadvantaged students

Students in the foster care system

Students experiencing houselessness

Students in the juvenile justice system

Students with disabilities

What are the top core tags selected when disaggregated?

By locale

By level

##By school type

##By leadership team

By leadership team

I collapsed leadership team diversity variable in two:
predominantly White = 0-49% BIPOC leadership
predominantly BIPOC = 50% + BIPOC leadership

core_lead <- full %>% 
  select(school_id, lead = leadership_diversity, starts_with("core")) %>% 
  filter(!lead == 0) %>% 
  filter(!lead == 5) %>% 
  mutate(lead = case_when(
    (lead == 1 | lead == 2) ~ "PWI",
    (lead == 3 | lead == 4) ~ "BIPOC"
  )) %>%
  rename_all(funs(sub("core", "practices", .))) %>% 
  pivot_longer(cols = starts_with("practices"),
               names_to = "tag",
               values_to = "n") %>% 
  select(!school_id) %>% 
  mutate(rate = rep(1, nrow(.))) %>% 
  group_by(lead, tag) %>% 
  summarize(n = sum(n),
            rate = sum(rate),
            pct = n/rate) %>% 
  ungroup() %>% 
  group_by(lead) %>% 
  arrange(desc(n), .by_group = TRUE) %>% 
  slice(1:6) #tie at spot #5 for one group
## Warning: `funs()` was deprecated in dplyr 0.8.0.
## ℹ Please use a list of either functions or lambdas:
## 
## # Simple named list: list(mean = mean, median = median)
## 
## # Auto named with `tibble::lst()`: tibble::lst(mean, median)
## 
## # Using lambdas list(~ mean(., trim = .2), ~ median(., na.rm = TRUE))
## Call `lifecycle::last_lifecycle_warnings()` to see where this warning was
## generated.
## `summarise()` has grouped output by 'lead'. You can override using the
## `.groups` argument.
#predominantly white
pwcore_plot <- core_lead %>% 
  filter(lead == "PWI") %>% 
  ggplot(., aes(reorder(tag, pct), pct)) +
  geom_col(fill = transcend_cols[1]) +
  scale_x_discrete(labels = label_tags(wrap = 25)) +
  coord_flip() +
  scale_y_continuous(limits = c(0, 1), 
                     expand = c(0,0),
                     labels = scales::percent) +
  labs(title = "Top Core Practices in Schools\nled by Predominantly\nWhite Leadership Team",
       x = "",
       y = "percentage of schools")
pwcore_plot

#BIPOC-led
bipoccore_plot <- core_lead %>% 
  filter(lead == "BIPOC") %>% 
  ggplot(., aes(reorder(tag, pct), pct)) +
  geom_col(fill = transcend_cols[2]) +
  scale_x_discrete(labels = label_tags(wrap = 25)) +
  coord_flip() +
  scale_y_continuous(limits = c(0, 1), 
                     expand = c(0,0),
                     labels = scales::percent) +
  labs(title = "Top Core Practices in Schools\nled by Predominantly\nBIPOC Leadership Team",
       x = "",
       y = "percentage of schools")
bipoccore_plot

#combine plots
# combined_core <-
plot_grid(pwcore_plot, bipoccore_plot,
          ncol = 2)

# ggsave("finding-17b.png", plot = combined_core, path = here("final_products", "draft-findings"),
#        width = 12, height = 8, units = "in")